//
//  DKUnathorizedTableViewCell.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/25.
//

#import "DKUnathorizedTableViewCell.h"

static NSString * DK_UnauthorizedCellId = @"DK_UnauthorizedCellId";
@interface DKUnathorizedTableViewCell()
@property (nonatomic, strong)UILabel * unathorizedHeadLab;
@end
@implementation DKUnathorizedTableViewCell
+ (instancetype)unauthorizedCell:(UITableView *)tableView{
    DKUnathorizedTableViewCell * dk_UnathorizedTableViewCell = [tableView dequeueReusableCellWithIdentifier:DK_UnauthorizedCellId];
    if (!dk_UnathorizedTableViewCell) {
        dk_UnathorizedTableViewCell = [[DKUnathorizedTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DK_UnauthorizedCellId];
    }
    dk_UnathorizedTableViewCell.backgroundColor = [UIColor clearColor];
    dk_UnathorizedTableViewCell.selectionStyle = UITableViewCellSelectionStyleNone;
    dk_UnathorizedTableViewCell.accessoryType = UITableViewCellAccessoryNone;
    return dk_UnathorizedTableViewCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = UIColor.whiteColor;
        self.layer.cornerRadius = DK_IsWidthScale(20);
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UIView *UnauthorizedMainBillView = [[UIView alloc] init];
    UnauthorizedMainBillView.backgroundColor = UIColor.whiteColor;
    UnauthorizedMainBillView.layer.cornerRadius = DK_IsWidthScale(20);
    UnauthorizedMainBillView.clipsToBounds = YES;
    [self addSubview:UnauthorizedMainBillView];
    [UnauthorizedMainBillView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(10)));
    }];
    
    self.unathorizedHeadLab = [[UILabel alloc] init];
    self.unathorizedHeadLab.textColor = DK_Hex(@"#333333");
    self.unathorizedHeadLab.font = DK_FONT_Medium(15);
    [UnauthorizedMainBillView addSubview:self.unathorizedHeadLab];
    [self.unathorizedHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    UIButton * unathorizedBtn = [[UIButton alloc] init];
    [unathorizedBtn setBackgroundImage:DK_GetImage(@"dk_MainNextMore") forState:UIControlStateNormal];
    [unathorizedBtn addTarget:self action:@selector(unathorized) forControlEvents:UIControlEventTouchUpInside];
    [UnauthorizedMainBillView addSubview:unathorizedBtn];
    [unathorizedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.height.equalTo(@(DK_IsWidthScale(16)));
        make.width.equalTo(@(DK_IsWidthScale(16)));
    }];
}
- (void)unathorized{
    
}
-(void)setUnathorizedType:(UnathorizedType)unathorizedType{
    _unathorizedType = unathorizedType;
    if(_unathorizedType == UnathorizedTypeBankCard){
        self.unathorizedHeadLab.text = @"Bank card";
    }else if(_unathorizedType == UnathorizedTypePrivacy){
        self.unathorizedHeadLab.text = @"Privacy Agreement";
    }
}
@end
